<template>
  <div class="SearchPro-body">
    <van-dropdown-menu>
      <van-dropdown-item disabled title="综合" />
      <van-dropdown-item
        title="价格"
        v-model="value1"
        :options="option1"
        @change="pricechange"
      />
      <van-dropdown-item
        title="分类"
        v-model="menuVal"
        :options="filterCategory"
        @change="categoryVal"
      />
    </van-dropdown-menu>
    <!-- 搜索提示 -->
    <!-- 如果有数据就显示列表，如果没有就为空-->
    <van-empty v-if="goodsList.length===0" image="search" description="没有搜索到相关产品" />
    <products v-else :goodsList="goodsList"></products>
  </div>
</template>

<script>
import products from "@/components/products/products.vue";
export default {
  props: ["filterCategory", "goodsList"],
  components: {
    products,
  },
  data() {
    return {
      menuVal: 1005001,
      value1: "desc",
      option1: [
        { text: "价格由高到低", value: "desc" },
        { text: "价格由低到高", value: "asc" },
      ],
      // option2: [
      //   { text: "全部", value: "a" },
      //   { text: "居家", value: "b" },
      // ]
    };
  },
  created() {},
  updated() {
    // console.log('filterCategory',this.filterCategory)
    //拿到menuVal，并且要做成活的，当checked:true时才显示
    this.filterCategory.map((item) => {
      if (item.checked) {
        this.menuVal = item.value;
      }
    });
  },
  mounted() {},
  methods: {
    categoryVal(val) {
      //val为id
      //子传父
      this.$emit("categoryVal", val);
    },
    pricechange(val) {
      this.$emit("pricechange", val);
    },
  },
};
</script>

<style scoped lang="less">
.products{
  background-color: #eee !important;
}
</style>
